package com.ibeeking.found.msg.rest.controller.v1;

import com.ibeeking.found.common.annotation.LoginUser;
import com.ibeeking.found.common.entity.CurrentUser;
import com.ibeeking.found.msg.rest.service.IWxMpMenuService;
import com.ibeeking.found.msg.service.common.param.WxMpMenuParam;
import com.ibeeking.found.msg.service.common.vo.WxMpMenuVO;
import com.ibeeking.nematos.constants.enums.OperateLogTypeEnum;
import com.ibeeking.nematos.log.annotation.Log;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @ClassName WxmpWxMenuController控制器
 * @Description
 * @Author ibeeking
 * @Date 2020-12-30 11:34
 **/
@RestController
@RequestMapping("/b/wxMp/menu/v1")
public class WxMpMenuController {

    @Resource
    private IWxMpMenuService mpMenuServiceImpl;

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查询公众号菜单")
    @GetMapping(value = "/queryMenu/{appId}")
    public WxMpMenuVO queryMenu(@PathVariable("appId") String appId) {
        return mpMenuServiceImpl.queryMenu(appId);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "保存并发布微信公众号菜单")
    @PostMapping(value = "/saveAndReleasea")
    public Boolean saveAndReleasea(@LoginUser CurrentUser currentUser, @RequestBody @Validated WxMpMenuParam param) {
        return mpMenuServiceImpl.saveAndReleasea(currentUser.getId(), param);
    }

}
